package com.ruoyi.dispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dispatch.domain.WorkfaceInfo;
import com.ruoyi.dispatch.service.IWorkfaceInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工作面信息Controller
 * 
 * @author wuxiaofang
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/dispatch/workfaceInfo")
@Anonymous
public class WorkfaceInfoController extends BaseController
{
    @Autowired
    private IWorkfaceInfoService workfaceInfoService;

    /**
     * 查询工作面信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:workfaceInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkfaceInfo workfaceInfo)
    {
        startPage();
        List<WorkfaceInfo> list = workfaceInfoService.selectWorkfaceInfoList(workfaceInfo);
        return getDataTable(list);
    }

    /**
     * 导出工作面信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:workfaceInfo:export')")
    @Log(title = "工作面信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkfaceInfo workfaceInfo)
    {
        List<WorkfaceInfo> list = workfaceInfoService.selectWorkfaceInfoList(workfaceInfo);
        ExcelUtil<WorkfaceInfo> util = new ExcelUtil<WorkfaceInfo>(WorkfaceInfo.class);
        util.exportExcel(response, list, "工作面信息数据");
    }

    /**
     * 获取工作面信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:workfaceInfo:query')")
    @GetMapping(value = "/{workfaceId}")
    public AjaxResult getInfo(@PathVariable("workfaceId") Long workfaceId)
    {
        return success(workfaceInfoService.selectWorkfaceInfoByWorkfaceId(workfaceId));
    }

    /**
     * 新增工作面信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:workfaceInfo:add')")
    @Log(title = "工作面信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkfaceInfo workfaceInfo)
    {
        return toAjax(workfaceInfoService.insertWorkfaceInfo(workfaceInfo));
    }

    /**
     * 修改工作面信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:workfaceInfo:edit')")
    @Log(title = "工作面信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkfaceInfo workfaceInfo)
    {
        return toAjax(workfaceInfoService.updateWorkfaceInfo(workfaceInfo));
    }

    /**
     * 删除工作面信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:workfaceInfo:remove')")
    @Log(title = "工作面信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workfaceIds}")
    public AjaxResult remove(@PathVariable Long[] workfaceIds)
    {
        return toAjax(workfaceInfoService.deleteWorkfaceInfoByWorkfaceIds(workfaceIds));
    }
}
